﻿/***************************************************************************
 *		ElGee Google Chart API Helper
 *		Copyright(C) 2011 by Laurent Geffroy lgeffroy@gmail.com
 * 
 *		This program is free software; you can redistribute it and/or 
 *		modify it under the terms of the GNU General Public License as
 *		published by the Free Software Foundation; either version 2 of 
 *		the License, or (at your option) any later version.
 *		
 *		This program is distributed WITHOUT ANY WARRANTY; without even the
 *		implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
 *		See the GNU General Public License for more details.
 *	
 *      For particular licensing, please contact me at lgeffroy@gmail.com
 *****************************************************************************/
using System;
using System.Text;

namespace ElGee.Google.Charts
{
    public class FontWithColor : FontBase
    {
        /// <summary>
        /// Gets or sets the color.
        /// </summary>
        /// <value>The color.</value>
        public String Color { get; set; }

        /// <summary>
        /// Gets a value indicating whether this instance is empty.
        /// </summary>
        /// <value><c>true</c> if this instance is empty; otherwise, <c>false</c>.</value>
        public override bool IsEmpty
        {
            get
            {
                if (!base.IsEmpty)
                    return false;

                if (String.IsNullOrWhiteSpace(Color))
                    return true;

                return false;
            }
        }

        /// <summary>
        /// Returns a <see cref="System.String"/> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String"/> that represents this instance.
        /// </returns>
        public override string ToString()
        {

            if (IsEmpty)
                return String.Empty;
            
            var sb = new StringBuilder();
            if (!String.IsNullOrWhiteSpace(Color))
                sb.Append("color: '").Append(SecureString(Color)).Append("',");
            if (!String.IsNullOrWhiteSpace(FontName))
                sb.Append("fontName: '").Append(SecureString(Color)).Append("',");
            if (FontSize != 0)
                sb.Append("fontSize: ").Append(SecureString(Color)).Append(",");

            // Removing the last comma of the legendTextStyle
            sb.Remove(sb.Length - 1, 1);

            return sb.ToString();            
        }
    }
}
